#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    //QMenuBar* menuBar=new QMenuBar();
    QMenuBar* menuBar=this->menuBar();
    this->setMenuBar(menuBar);

    QMenu* menu=new QMenu("菜单");
    menu->setIcon(QIcon(":/save.png"));
    menuBar->addMenu(menu);

    QMenu* menuChild=new QMenu("子菜单1");
    menu->addMenu(menuChild);
    menuChild->setIcon(QIcon(":/save.png"));

    QAction* action1=new QAction("菜单项1");
    action1->setIcon(QIcon(":/save.png"));
    QAction* action2=new QAction("菜单项2");
    action2->setIcon(QIcon(":/file.png"));
    menu->addAction(action1);
    menu->addSeparator();
    menu->addAction(action2);
}

MainWindow::~MainWindow()
{
    delete ui;
}
